
package com.scs.application.modules.settlement.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.scs.application.core.service.IBaseService;
import com.scs.application.modules.settlement.dto.InvoiceBuildDTO;
import com.scs.application.modules.settlement.dto.InvoiceDTO;
import com.scs.application.modules.settlement.entity.Invoice;
import com.scs.application.modules.settlement.request.InvoiceQueryRequest;
import com.scs.application.modules.settlement.vo.InvoiceVO;
import com.scs.application.modules.thirdparty.request.InvoiceRequest;
import org.springframework.transaction.annotation.Transactional;

import javax.validation.Valid;
import java.io.Serializable;
import java.util.List;

/**
 * 开票单 service 接口
 */
public interface InvoiceService extends IBaseService<Invoice> {

    List<Invoice> list(InvoiceQueryRequest request);


    IPage<Invoice> page(InvoiceQueryRequest request);

    /**
     * 添加开票单
     *
     * @param entity
     */
    boolean add(Invoice entity);

    /**
     * 撤销开票
     * @param entity
     */
    void cancel(Invoice entity);

    /**
     * 审核 将状态从制单状态0改为已审核1
     */
    void audit(Invoice invoice);


    Double saveInvoice(InvoiceDTO invoiceDTO);

    boolean deleteInvoiceById(String id);

    /**恢复结算单到待审核状态 */
    boolean resumeInvoice(String id);

    List<InvoiceVO> getInvoices(InvoiceRequest invoiceRequest);

    /**
     * 计算开票单金额
     * @param invoiceId
     */
    void calculatePrice(String invoiceId);

    @Transactional(rollbackFor = Exception.class)
    void deleteBatchItem(List<Serializable> ids);

    // 开票操作
    List<Invoice> buildInvoice(@Valid InvoiceBuildDTO invoiceDTO);
}
